<template>
  <div>
    <div class="wordPreview" v-if="content">
      <div v-html="content"></div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
import { ref, onMounted, reactive } from "vue";
import mammoth from "mammoth";
const props = defineProps({
  fileUrl: {
    type: String,
    required: true,
  },
});
onMounted(() => {
  getContent();
});
const content = ref("");
const getContent = async () => {
  const response = await fetch(props.fileUrl);
  const arrayBuffer = await response.arrayBuffer();
  const result = await mammoth.convertToHtml({ arrayBuffer });
  content.value = result.value;
};
</script>

<style lang="scss" scoped>
.wordPreview {
  width: 100%;
  height: 100%;
  border: 1px solid rgba(155, 155, 155, 0.2);
  box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;
  padding: 20px;
  box-sizing: border-box;
}
</style>
